/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface.Fisica;

import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.net.URL;
import java.util.ArrayList;
import jogopoo.Grafico.GrafCenario;

/**
 *
 * @author user
 */
public final class Clip {

    public Clip(GrafCenario cena){
        sprite = new Image[1]; //background
        this.cena = cena;

    }

    public static void carregarImagens(Component component) throws InterruptedException
    {
        sprite = new Image[1];
        MediaTracker mediaTracker = new MediaTracker(component);


            URL url = Clip.class.getResource("/imagens/background02.jpg");
            sprite[0] = Toolkit.getDefaultToolkit().getImage(url);
            mediaTracker.addImage(sprite[0], 0);
        

        mediaTracker.waitForAll();
    }
    public void desenhaBackground(Graphics2D g2){
     g2.drawImage(this.sprite[0],0,0,cena);
    }
    public void desenha(Graphics2D g2,ArrayList<Planeta> lista_planeta){

        for(int i = 0;i < lista_planeta.size();++i)
          for(int j = 0;j < lista_planeta.get(i).getListaElipses().size();++j){
                g2.setClip(lista_planeta.get(i).getListaElipses().get(j));
                g2.drawImage(this.sprite[0],0,0,cena);
            }
       g2.setClip(null);
        }
  private GrafCenario cena;
  private static Image[]  sprite;//background
  }
